#pragma once
#include <iostream>
#include <memory>
#include <vector>
using namespace std;
//子系统类Light
class Light{
public:
	Light(string position){
		this->position = position;
	}
	
	void on(){
		cout << this->position << "灯打开!" << endl;
	}
	
	void off(){
		cout << this->position << "灯关闭!" << endl;
	}
	
private:
	string position;
}; 


//子系统类Fan
class Fan{
public:
	void on(){
		cout << "风扇打开!" << endl;
	}
	
	void off(){
		cout << "风扇关闭!" << endl;
	}
}; 

//子系统类AirConditioner
class AirConditioner{
public:
	void on(){
		cout << "空调打开!" << endl;
	}
	
	void off(){
		cout << "空调关闭!" << endl;
	}	
}; 

//子系统类Television
class Television{
public:
	void on(){
		cout << "电视机打开!" << endl;
	}
	
	void off(){
		cout << "电视机关闭!" << endl;
	}	
}; 


//外观类GeneralSwitchFacade
class GeneralSwitchFacade{
public:
	GeneralSwitchFacade(){
		lights.push_back(make_shared<Light>("左前"));
		lights.push_back(make_shared<Light>("右前"));
		lights.push_back(make_shared<Light>("左后"));
		lights.push_back(make_shared<Light>("右后"));
		fan = make_shared<Fan>();
		ac = make_shared<AirConditioner>();
		tv = make_shared<Television>();
	}
	
	void on(){
		for(auto light : lights){
			light->on();
		}
		fan->on();
		ac->on();
		tv->on();
	}
	
	void off(){
		for(auto light : lights){
			light->off();
		}
		fan->off();
		ac->off();
		tv->off();
	}
	
	
private:
	vector<shared_ptr<Light> > lights;
	shared_ptr<Fan> fan;
	shared_ptr<AirConditioner> ac;
	shared_ptr<Television> tv;
}; 

